﻿using eProcurement.BLL;
using eProcurement.controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace eProcurement.members
{
    public partial class Categories : System.Web.UI.Page
    {
        protected void Page_Load( object sender, EventArgs e )
        {
            if ( !IsPostBack )
            {
                Manager manager = new Manager();
                List<string> cateories = Manager.GetIndustryCategories( Server.MapPath( "../Xml/IndustryCategory.xml" ) );
                
                lbl1.InnerText = manager.GetNumberProjects( "Agricultural/ Forestry/ Mining" ).ToString();
                lbl2.InnerText = manager.GetNumberProjects( "Energy/ Fuel/ Chemical" ).ToString();
                lbl3.InnerText = manager.GetNumberProjects( "Medical/ Surgical/ Health" ).ToString();
                lbl4.InnerText = manager.GetNumberProjects( "Telecommunications" ).ToString();

                foreach ( string category in cateories )
                {
                    int numberprojects = manager.GetNumberProjects( category );
                    CategoryItemControl control = (CategoryItemControl)LoadControl( "../controls/CategoryItemControl.ascx" );
                    control.Setup( category, numberprojects );
                    container.Controls.Add( control );
                }
            }
        }
    }
}